package com.hhx.utils;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import javax.sql.DataSource;
import java.util.Properties;
public class BaseDao {
    //检索配置文件jdbc.properties键值对
    private static Properties p = new Properties();
    private static DataSource dataSource;
    static {//加载配置文件
        try {
            p.load(BaseDao.class.getClassLoader().getResourceAsStream("/jdbc.properties"));
            dataSource = DruidDataSourceFactory.createDataSource(p);
            System.out.println("Loading configuration successfully");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static DataSource getDataSource() {
        return dataSource;
    }
}
